#include "votesys.h"
#include<stdio.h>
#include<string.h>
#include<assert.h>
#include<stdlib.h>

#define LEN 80

int 
main(int argc, char* argv[])
{
  CLIENT *cl;
  voteStatus status;
  int i;
  char *name;
  name = (char*)malloc(sizeof(char)*LEN);
 

  if(argc < 2)
  {
    fprintf(stderr, "Please input the name of artist\n"); 
    return -1;
  }
  
  cl = clnt_create("localhost", VOTESYS, VOTEVERS, "tcp");
  
  if( cl == NULL )
  {
     clnt_pcreateerror("Server"); 
     return -1;
  }

  name[0] = '\0';
  for(i=1; i<argc; i++)
  {
    assert(strcat(name, argv[i]) != (char*)NULL);   
  }
  
//  if( vote_1(&name, &status, cl) != RPC_SUCCESS )
  //struct svc_req *rqstp; 
  
//  printf("%s\n", name);
  if( vote_1(&name, &status, cl) != RPC_SUCCESS )
  {
      
      clnt_perror(cl, "Server"); 
      return -1;
  }
  
  if( status == vsInvalidVoter )
  {
    printf("The voting is close\n");

  }
  else
  {
   printf("submitVote: ok %d\n", status);
  }


  return 0;

}
